package 贪心.easy;

/**
 * @author Lw中
 * @date 2020/8/24 9:52
 */
public class YiErErYi {

    public static int balancedStringSplit(String s) {
        int num = 0, res = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == 'L') {
                num ++;
            } else {
                num--;
            }
            if (num == 0) {
                res++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int n = balancedStringSplit("LLSLLSLSSS");
        System.out.println(n);
    }

}
